<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>@ViewBag.Title</title>
<link rel="Stylesheet" type="text/css"
	href='${pageContext.request.contextPath}/Content/blogManager.css' />
<script type="text/javascript"
	src="${pageContext.request.contextPath }/script/jquery-1.10.2.js"></script>
<script type="text/javascript">
	$(function() {
		$(".deleteId").each(
				function() {
					$(this).click(
							function() {
								if (confirm("确认删除"
										+ $(this).prev("input[type=hidden]")
												.val() + "吗？")) {
									$.ajax({
										type : "POST",
										data : "articleId="
												+ $(this).attr("rel"),
										url : "delete",
										dataType : "json",
										success : function() {
											alert("删除成功");
										}
									});
								}
							});
				});
		
		$("#reset").click(function() {
			location.href="manage";
		});
	});
</script>
<style type="text/css">
#info {
	margin: 10px;
}

#info a {
	text-decoration: none;
}

#info h3 {
	text-indent: 3em;
	background: url('Content/images/ihome-main-bg.gif') repeat-x;
	padding: 5px 0px;
}

#info hr {
	margin: 7px 0px;
}

#info p {
	text-align: right;
	margin-bottom: 5px;
}

#info div table {
	width: 780px;
}

thead {
	font-weight: bold;
	text-align: center;
}

td {
	padding: 3px 0px;
}

#article tbody tr:nth-of-type(odd) {
	background-color: #F0F8FF;
}

#info .sp1 {
	width: 550px;
}

#info .sp2 {
	width: 35px;
}
</style>
</head>
<body>
	<div id="wrapper">
		<s:action name="backHeader" namespace="/" executeResult="true"></s:action>
		<div id="content">
			<s:action name="backSidebar" namespace="/" executeResult="true"></s:action>
			<div id="main">
				<div id="info">
					<h3>我的博文</h3>
					<form action="manage" method="get">
						<input type="hidden" value="${userId }" name="userId" />
						<p>
							<a href="editPage">发表文章&gt;&gt;</a>
						</p>
						博文分类： <select name="cid" id="cid">
							<option value="0">全部</option>
							<c:forEach items="${categoryList }" var="c">
								<c:if test="${cid ==c.id }">
									<option value="${c.id }" selected="selected">${c.name }</option>
								</c:if>
								<c:if test="${cid !=c.id }">
									<option value="${c.id }">${c.name }</option>
								</c:if>
							</c:forEach>
						</select> &nbsp;&nbsp;博文标题: <input type="text" name="title" id="title" 
							value="${title }" /> &nbsp;&nbsp;<input type="submit" value="查询" />
						&nbsp;&nbsp;<input type="button" id="reset" value="重置" />
					</form>
					<hr />
					<div id="article">
						<table>
							<thead>
								<tr>
									<td class="sp1">博文标题</td>
									<td>最后更新时间</td>
									<td class="sp2">删除</td>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${articleList }" var="a">
									<tr>
										<td class="sp1"><a href="editPage?articleId=${a.id}">${a.title }</a></td>
										<td>${a.updateTime }</td>
										<td class="sp2"><input type="hidden" value="${a.title }"
											id="title" /> <input type="button" class="deleteId"
											rel="${a.id }" value="删除"></td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
					</div>
				</div>
			</div>
			<div class="clearBoth"></div>
		</div>
		<%@include file="../shared/footer.jsp"%>

	</div>
</body>
</html>